﻿	      <?php include("conn.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{
	public $title;
	public $price;
	public $images;
	public $name;
	public $goodsid;
	public $number;
	public $gname;
	public $numbers;
	public $classify;
	public $brand;
	public $produce;
	public $state;
	public $zongjia;
	public $sd;
	public $sum;

	function __construct($title,$price,$images,$name,$goodsid,$number,$gname,$numbers,$classify,$brand,$produce,$state,$zongjia,$sd,$sum)
	{
		$this->title      = $title;
		$this->price = $price;
		$this->images     = $images;
		$this->name      = $name;
		$this->goodsid    = $goodsid;
		$this->number    = $number;
		$this->gname   = $gname;
		$this->numbers    = $numbers;
		$this->classify    = $classify;
		$this->brand    = $brand;
		$this->produce   = $produce;
		$this->state    = $state;
		$this->zongjia    = $zongjia;
		$this->sd    = $sd;
		$this->sum    = $sum;
	}
}


if($_REQUEST['page']!="")
{
$de=$_REQUEST['page']*$_REQUEST['pagesize'];
$size=$_REQUEST['pagesize'];
}

else
{
$de=0;
$size=5;
}


	$uid=2;
	$sta=$_REQUEST[state];
	
	$prize = array();
		$rert30=mysql_query("select *from goodsorders where userid='".$_REQUEST[userid]."'  and state='".$sta."' order by ordersid desc  limit $de,$size");
	
	while($rowf=mysql_fetch_array($rert30)){
	
	 $rert31=mysql_query("select *from car where ordersid ='".$rowf[ordersid]."'");
$rowf1=mysql_fetch_array($rert31);
$yanse=$rowf1[caizhi].$rowf1[caizhi];

$rert34=mysql_query("select SUM(number) as total from car where ordersid ='".$rowf[ordersid]."'");
$rowf4=mysql_fetch_array($rert34);
   
 $rert32=mysql_query("select *from shop where  shopid ='".$rowf[shopid]."'");
$rowf2=mysql_fetch_array($rert32);

$rert33=mysql_query("select *from goods where goodsid ='".$rowf1[goodsid]."'");
$rowf3=mysql_fetch_array($rert33);


       if($rowf[state]=="0")
	   {
	   $state="待付款";
	   $sds=  "<div class='fun_putst' onclick=delet('".$rowf[ordersid]."')>
				   删除订单
				   </div>
				   <button onClick=openW('zhi_fu_win','".$rowf['totalprice']."','".$rowf[ordersid]."')>
				   付款
				   </div><div class='clear'></div>";
	   }
			
			   else if($rowf[state]=="1")
	   {
	   $state="待发货";
	   $sds=  "<div class='fun_putstgr' onclick=openzhis('shouhuo','shouhuo.html','".$rowf[ordersid]."') >
				   申请售后
				   </div>";
	   }
	   else if($rowf[state]=="2")
	   {
	   $state="待收货";
	   $sds=  "<div class='fun_putstgr' onclick=shouhuo('".$rowf[ordersid]."')>
				   确认收货
				   </div>
				   <div class='fun_putst' data-url='http://m.kuaidi100.com/index_all.html?type=".$rowf[kuaidi]."&postid=".$rowf[danhao]."'  data-title='物流咨询' onClick='toDetail(this);'>
				   查看物流
				   </div>
				   <div class='fun_putstgr' onclick=openzhis('shouhuo','shouhuo.html','".$rowf[ordersid]."') >
				   申请售后
				   </div>
				   ";
	   }

   else if($rowf[state]=="3")
	   {
	   $state="待评价";
	   $sds=  "<div class='fun_putstgr' onclick=openzhis('pingjia','pingjia.html','".$rowf[ordersid]."')>
				   去评价
				   </div>
				    <div class='fun_putst' data-url='http://m.kuaidi100.com/index_all.html?type=".$rowf[kuaidi]."&postid=".$rowf[danhao]."'  data-title='物流咨询' onClick='toDetail(this);'>
				   查看物流
				   </div>
				   <div class='fun_putst' onclick=openzhis('shouhuo','shouhuo.html','".$rowf[ordersid]."') >
				   申请售后
				   </div>
				   ";
	   }
	    else if($rowf[state]=="4")
	   {
	   $state="售后/退款";
	   $sds=  "<div class='fun_putstgr' onclick=openzhis('pingjia','shouhuo.html','".$rowf[ordersid]."')>
				   售后/退款
				   </div>
				    <div class='fun_putst' data-url='http://m.kuaidi100.com/index_all.html?type=".$rowf[kuaidi]."&postid=".$rowf[danhao]."'  data-title='物流咨询' onClick='toDetail(this);'>
				   查看物流
				   </div>
				   ";
	   }
 else if($rowf[state]=="5"){
	   $state="交易完成";
	   $sds=  "<div class='fun_putst' data-url='http://m.kuaidi100.com/index_all.html?type=".$rowf[kuaidi]."&postid=".$rowf[danhao]."'  data-title='物流咨询' onClick='toDetail(this);'>
				   查看物流
				   </div>
				   ";
	   }
	   
	    else {
	   $state="交易关闭";
	   $sds=  "";
	   }

			$prize[] = new MyPrizeBean($rowf3['title'],$rowf3['price'],$rowf3['images'],$rowf2['name'],$rowfs['goodsid'],$rowf1['number'],$rowf3['name'],$rowf1['numbers'],$rowf3['summary'],$rowf3['brand'],$yanse,$state,$rowf['totalprice'],$sds,$rowf4[total]);
		
	}

echo json_encode($prize);


?>